Allow defining custom providers for more "thingatpt" functions
authorJim Porter <jporterbugs@gmail.com>
Mon, 29 Apr 2024 04:19:53 +0000 (21:19 -0700)
committerJim Porter <jporterbugs@gmail.com>
Mon, 20 May 2024 01:31:58 +0000 (18:31 -0700)
commitae9045a8bd8d3917feb570adfab0b929b120a8e5
tree8f2b6fe42d5a2f66f6c9ace62aed90a186e31939
parenta1b24ebc83e3df67d2e12870b4bea941b21cebda
Allow defining custom providers for more "thingatpt" functions

This also fixes an issue in EWW and bug-reference-mode where
(thing-at-point 'url) at the end of a URL would return nil.

See <https://lists.gnu.org/archive/html/emacs-devel/2024-02/msg00200.html>.

* lisp/thingatpt.el (forward-thing-provider-alist)
(bounds-of-thing-at-point-provider-alist): New variables...
(forward-thing, bounds-of-thing-at-point): ... use them.
(text-property-search-forward, text-property-search-backward)
(prop-match-beginning, prop-match-end): Declare.
(thing-at-point-for-text-property, forward-thing-for-text-property)
(bounds-of-thing-at-point-for-text-property): New functions.

* lisp/net/eww.el (eww--url-at-point): Use
'thing-at-point-for-text-property'.
(eww--bounds-of-url-at-point, eww--forward-url): New functions...
(eww-mode): ... use them.

* lisp/progmodes/bug-reference.el (bug-reference--url-at-point): Use
'thing-at-point-for-text-property'.
(bug-reference--bounds-of-url-at-point, bug-reference--forward-url): New
functions...
(bug-reference--init): ... use them.

* test/lisp/thingatpt-tests.el (thing-at-point-providers)
(forward-thing-providers, bounds-of-thing-at-point-providers): New
tests.

* etc/NEWS: Announce this change.
etc/NEWS
lisp/net/eww.el
lisp/progmodes/bug-reference.el
lisp/thingatpt.el
test/lisp/thingatpt-tests.el